package com.ruoyi.hospital.controller.storeInfo;

import java.util.List;

import com.ruoyi.common.utils.StringUtils;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hospital.domain.storeInfo.PharmacyDrugNon;
import com.ruoyi.hospital.service.storeInfo.IPharmacyDrugNonService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 非药品库信息Controller
 * 
 * @author wendao
 * @date 2024-08-19
 */
@RestController
@RequestMapping("/hospital/pharmacyDrugNon")
public class PharmacyDrugNonController extends BaseController
{
    @Autowired
    private IPharmacyDrugNonService pharmacyDrugNonService;

    /**
     * 查询非药品库信息列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:pharmacyDrugNon:list')")
    @GetMapping("/list")
    public TableDataInfo list(PharmacyDrugNon pharmacyDrugNon)
    {
        startPage();
        List<PharmacyDrugNon> list = pharmacyDrugNonService.selectPharmacyDrugNonList(pharmacyDrugNon);
        return getDataTable(list);
    }

    /**
     * 导出非药品库信息列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:pharmacyDrugNon:export')")
    @Log(title = "非药品库信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PharmacyDrugNon pharmacyDrugNon)
    {
        List<PharmacyDrugNon> list = pharmacyDrugNonService.selectPharmacyDrugNonList(pharmacyDrugNon);
        ExcelUtil<PharmacyDrugNon> util = new ExcelUtil<PharmacyDrugNon>(PharmacyDrugNon.class);
        util.exportExcel(response, list, "非药品库信息数据");
    }

    /**
     * 获取非药品库信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:pharmacyDrugNon:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(pharmacyDrugNonService.selectPharmacyDrugNonById(id));
    }

    /**
     * 新增非药品库信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:pharmacyDrugNon:add')")
    @Log(title = "非药品库信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PharmacyDrugNon pharmacyDrugNon)
    {
        return toAjax(pharmacyDrugNonService.insertPharmacyDrugNon(pharmacyDrugNon));
    }

    /**
     * 修改非药品库信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:pharmacyDrugNon:edit')")
    @Log(title = "非药品库信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PharmacyDrugNon pharmacyDrugNon)
    {
        return toAjax(pharmacyDrugNonService.updatePharmacyDrugNon(pharmacyDrugNon));
    }

    /**
     * 删除非药品库信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:pharmacyDrugNon:remove')")
    @Log(title = "非药品库信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(pharmacyDrugNonService.deletePharmacyDrugNonByIds(ids));
    }
}